package com.wva.common.config;

import com.wva.common.interceptor.AuthContextInterceptor;
import com.wva.common.interceptor.LogContextInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册日志上下文拦截器
        registry.addInterceptor(new LogContextInterceptor())
                .addPathPatterns("/**");

        //注册认证上下文拦截器
        registry.addInterceptor(new AuthContextInterceptor())
                .addPathPatterns("/**");
    }
}
